#include "player.h"


Player::Player(b2World *world, glm::vec2 pos, glm::vec2 size, Texture2D sprite, glm::vec3 color)
	:GameObject()
{
	mColor = color;
	mSprite = sprite;
	mSize = size;

	b2BodyDef def;
	def.type = b2_dynamicBody;
	def.position.Set(pos.x, pos.y);
	mPhysicBody = world->CreateBody(&def);
	// set shape
	b2PolygonShape shape;
	shape.SetAsBox(size.x / 2, size.y / 2);
	// define fixture
	b2FixtureDef fixDef;
	fixDef.shape = &shape;
	fixDef.density = 1.f;
	fixDef.friction = 0.f;
	fixDef.restitution = 1.f;
	mPhysicBody->CreateFixture(&fixDef);

	mPhysicBody->SetFixedRotation(true);
	mPhysicBody->SetLinearDamping(10.f);

	mPhysicBody->SetUserData(this);

}




